package cn.edu.wynu.oop.permission;

public class BankAccount {
    private String accountNumber;
    private String accountName;
    private double balance;
    private String bankName;

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public String getAccountName() {
        return accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        if (balance < 0) {
            System.out.println("余额不能为负数");
            return;
        }
        this.balance = balance;
    }

    public String getBankName() {
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    public void withdraw(double amount) {
        if (amount <= 0) {
            System.out.println("取款金额必须大于0");
            return;
        }
        if (amount > balance) {
            System.out.println("余额不足");
            return;
        }
        this.balance -= amount;
        System.out.println("取款成功，当前余额为：" + balance);
    }

    public void deposit(double amount) {
        if (amount <= 0) {
            System.out.println("存款金额必须大于0");
            return;
        }
        this.balance += amount;
        System.out.println("存款成功，当前余额为：" + balance);
    }

    public BankAccount(String accountNumber, String accountName, double balance, String bankName) {
        this.accountNumber = accountNumber;
        this.accountName = accountName;
        this.balance = balance;
        this.bankName = bankName;
    }

    public static void main(String[] args) {
        BankAccount icbc = new BankAccount("1234567890", "张三",
                10000, "中国工商银行");
        icbc.deposit(1);
        icbc.withdraw(5000);
        icbc.withdraw(6000);
    }
}
